from .interfaces import *
from .data_manager import DataManager

class SimulationScene:
    def __init__(self, radar, targets, data_manager: DataManager):
        self.radar = radar
        self.targets = targets
        self.data_manager = data_manager
        self.current_time = 0.0
    
    def step(self, dt: float) -> SimulationFrame:
        """推进一个仿真步长"""
        # 获取真实轨迹点
        true_tracks = []
        for target in self.targets:
            position = target.get_position(self.current_time)
            true_tracks.append(TrackPoint(
                timestamp=self.current_time,
                position=position
            ))
        
        # 获取雷达测量
        measurements = self.radar.measure(true_tracks)
        
        # 创建仿真帧
        frame = SimulationFrame(
            timestamp=self.current_time,
            true_tracks=true_tracks,
            measurements=measurements
        )
        
        # 保存数据
        self.data_manager.add_frame(frame)
        
        self.current_time += dt
        return frame